import Vue from "vue";
import VueRouter from "vue-router";
import Login from "../views/Login.vue";
import Layout from "../layout/Index.vue";
import User from "../views/User.vue";
import Center from '../views/Center.vue'
import Test from '../views/Test.vue'

Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    redirect: "/login",
  },
  {
    path: "/login",
    name: "Login",
    component: Login,
  },
  {
    path: "/layout",
    name: "Layout",
    component: Layout,
    redirect: "/insert",
    children: [
      {
        path: "/user",
        component: User,
      },
      {
        path: "/center",
        component: Center,
      },
      {
        path: "/chart",
        component: Test,
      },
    ],
  },
];

const router = new VueRouter({
  routes,
});

// router.beforeEach((to, from, next) => {
//   if (localStorage.getItem("chartWebInfo")) {
//     next();
//   } else {
//     next({
//       path: '/login'
//     });
//   }
// })

export default router;
